<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Exp-Inlet-Gateway</title>
    <script src="../static/framework/jquery.min.js"></script>
    <script src="../static/framework/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="../static/framework/bootstrap.min.css">
    <style>
        body {
            background: #007bff;
            background: linear-gradient(to right, #0062E6, #33AEFF);
        }

        .btn-login {
            font-size: 0.9rem;
            letter-spacing: 0.05rem;
            padding: 0.75rem 1rem;
        }

        .btn-google {
            color: white !important;
            background-color: #ea4335;
        }

        .btn-facebook {
            color: white !important;
            background-color: #3b5998;
        }
    </style>


</head>
<body>
<div class="container">
    <div class="row">
        <div class="col-sm-9 col-md-7 col-lg-5 mx-auto">
            <div class="card border-0 shadow rounded-3 " style="margin-top: 15rem;">
                <div class="card-body p-4 p-sm-5">
                    <h5 class="card-title text-center mb-5 fw-light fs-5">Sign In</h5>
                    <form>
                        <div class="form-floating mb-3">
                            <input type="text" class="form-control" id="floatingUsername"
                                   placeholder="name@example.com">
                            <label for="floatingUsername">User Name</label>
                        </div>
                        <div class="form-floating mb-3">
                            <input type="password" class="form-control" id="floatingPassword" placeholder="Password">
                            <label for="floatingPassword">Password</label>
                        </div>

                        <div class="form-check mb-3">
                            <input class="form-check-input" type="checkbox" value="" id="rememberPasswordCheck">
                            <label class="form-check-label" for="rememberPasswordCheck">
                                Remember password
                            </label>
                        </div>
                        <div class="d-grid">
                            <button class="btn btn-primary btn-login text-uppercase fw-bold" type="submit"
                                    onclick="loginIn()">Sign in
                            </button>
                        </div>
                        <hr class="my-4">
                        <div class="d-grid mb-2">
                            <button class="btn btn-google btn-login text-uppercase fw-bold" type="submit">
                                <i class="fab fa-google me-2"></i> Sign in with Google
                            </button>
                        </div>
                        <div class="d-grid">
                            <button class="btn btn-facebook btn-login text-uppercase fw-bold" type="submit">
                                <i class="fab fa-facebook-f me-2"></i> Sign in with Facebook
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    function loginIn() {
        const form = {
            username: $("#floatingUsername").val(),
            password: $("#floatingPassword").val(),
        }
        debugger
        $.ajax({
            type: "post",
            url: '/login/in',
            async: false,
            data: JSON.stringify(form),
            dataType: "json",
            success: function (result) {
                if (result.code !== 200) {
                    $.showNotice("ERROR", "获取数据失败");
                    console.log("获取失败", result);
                    return;
                }
                console.log(result);
                window.location.href = result.data;
                history.pushState('', '', result.data);
            },
            error: function (msg) {
                console.log("获取失败", msg);
                $.showNotice("ERROR", "获取应用失败");
            }
        });
    }
</script>
</html>